﻿@model WebUI.Models.UserMemo

@using (Html.BeginForm(null, null, new { IsView = false }, FormMethod.Post, new { enctype = "multipart/form-data" }))
{
    var rds = SiteUser.UserAllRecupers.Where(v => v.GuoQi == false).SelectMany(v => v.QizSubjectObjForDoctors).OrderByDescending(v => v.Timemark);
        
    var items = rds.Select(v => new { RecuperID = v.RecuperID, Title =v.Doctor.UserName }).Distinct().ToList();
    //var items = SiteUser.UserAllRecupers.Where(v => v.GuoQi == false).Select(v => new { RecuperID = v.RecuperID, Title = (v.Hospital.HospCode + v.BingQu.Title + v.Department.DepName + v.Doctor.UserName + " " + v.EnHospDay.ToString("yyyy年M月")) }).ToList();
    items.Add(new { RecuperID = "", Title = "[私人备忘录]" });

    var Selects = new SelectList(items, "RecuperID", "Title", Model.RecuperID);
    
    @Html.ValidationSummary(true)
    <fieldset>
        <legend>健康备忘录</legend>
        @Html.HiddenFor(model => model.ID)
        @Html.HiddenFor(model => model.CreateTime)
        @Html.HiddenFor(model => model.UserID)
        <table width="100%">
            <tr>
                <td>
                    @Html.EditorFor(model => model.Title, "TxtField")
                    @Html.EditorFor(model => model.Timemark, "TxtField")
                    @Html.EditorFor(model => model.RecuperID, "SelField", new { Selects = Selects })
                    @Html.EditorFor(model => model.MemoText, "LongTxtField")
                    @Html.Hidden("memopicfile" + ".keep", Model.MemoPic)
                    <input name="memopicfile" type="file" onchange="fileInputCheck(this,0.8);" />
                </td>
                <td>
                    @if (!string.IsNullOrEmpty(Model.MemoPic))
                    {
                        var exts = new string[] { ".png", ".jpg", ".jpeg", ".gif" };
                        var ext = System.IO.Path.GetExtension(Model.MemoPic).ToLower();

                        if (exts.Contains(ext))
                        {
                        <a class="imagefield-view" target="_blank" href="@(Url.Action("Img", "Recuper", new { ID = Model.MemoPic, _newpage = "true" }))">
                            <img alt="照片" src="@(Url.Action("Img", "Recuper", new { ID = Model.MemoPic, Preview = true }))" />
                        </a>
                        }
                    }
                </td>
            </tr>
        </table>
        <p>
            @Helpers.SubmitButton("保存")
        </p>
    </fieldset>
}